home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 1 / Pier Shareware 1.iso / 033a / portest1.exe / TESTPORT.DOC < prev   
Text File  |  1992-09-15  |  23KB  |  469 lines

  1.    Slickware is Copy(c)right 1989,1992 by Gary M. Raymond, New Orleans, La.
  2.         Slick Port Modem Register Test Program V1.0 by Gary M. Raymond
  3.  
  4.                           Simple <Software> Company
  5.                               HOME of SlickWare
  6.  
  7.                               Gary M. Raymond
  8.                                 P.O.Box 8184
  9.                            New Orleans, La.  70182
  10.                                (504) 288-6550
  11.  
  12.  
  13.  
  14.    Files Provided:
  15.    ====================================================================
  16.  
  17.    TESTPORT.COM   5123 bytes    Comport test utility.
  18.    TESTPORT.DOC                 This document.
  19.  
  20.    TestPort will run on just about any version of DOS and with any
  21.    amount of RAM. If nothing else, TestPort will assist you in learning
  22.    more about serial communications and understanding your modem. Having
  23.    written and supported several terminal programs over the past seven
  24.    years, I have long ago realized that most problems involving terminal
  25.    software are actually modem or modem configuration problems. This
  26.    utility should take some of the mystery away from configuring,
  27.    understanding, and diagnosing serial communications hardware. If for
  28.    no other reason than curiosity, you owe it to your modem to use
  29.    TestPort at least once and read through this file. TestPort was
  30.    written in ASIC, and, I will gladly supply the source code with your
  31.    registration, if requested.
  32.  
  33.    ====================================================================
  34.    TestPort is a basic, easy to use, modem diagnostic tool. Although the
  35.    information TestPort provides will at first be seemingly cryptic to
  36.    the novice user, it can easily be learned and put to good use.  Bit
  37.    mapping the modem registers provides a wealth of information about
  38.    the state of your modem. Your modem is both configured and monitored
  39.    through these registers or electronic switches. Everything from baud
  40.    rate to data parity is determined by the one (on) or zero (off) bit
  41.    settings in these registers. Particular register bits are also used
  42.    to inform the terminal program that a character has arrived or is
  43.    ready to be transmitted along with numerous other useful information.
  44.  
  45.    According to the IBM scheme of things, you could have as many as
  46.    65,536 port addresses. These ports have an address in the hardware
  47.    set up according to IBM's scheme. Each address points to a one byte
  48.    location called a base address. Since we can both set and retrieve
  49.    bits in these bytes we refer to them as maskable base registers. Each
  50.    of the next subsequent nine bytes (BASE+1, BASE+2 etc) form that
  51.    ports general register set as outlined in the text below. Serial
  52.    communication ports begin with COM Port number one (COM1) with an
  53.    address assigned by IBM as decimal 1016 or 3F8 hex. Hence, the
  54.    address for the COM1 port register is 3F8. This is the place where a
  55.    byte of data is received (3F8 - Received Data Register) or sent (3F8
  56.    - Transmitter Holding Register) depending on requirements at the
  57.    moment. Therefore the base address allows indirect access to both the
  58.    THR and RDR (plus BRDL when bit 7 of LCR is set). The next register
  59.    (the IER) is located at this base address plus one, (3F8 + 1 = 3F9)
  60.    and so on.
  61.  
  62.    There are two general methods of obtaining bytes of data from a
  63.    serial port after it has been set up. The first involves stoping
  64.    every so often and looking to see if a byte has arrived, and if so,
  65.    taking it. This method of polling the modem registers is ok when
  66.    working at very slow baud rates. Polling is the method used by the
  67.    PC's Basic Input Output Service (BIOS firmware.) Unfortunately, if a
  68.    byte of data arrives before we have had a change to remove the
  69.    previous one, information can be lost. To overcome this drawback of
  70.    polling we can force the PC to react to the arrival of a byte by
  71.    removing and saving it in a special storage area until we have time
  72.    to use it. This is done by designing a special Interrupt Service
  73.    Routine (ISR) that will be activated instantly (no matter what else
  74.    the PC may be doing) to collect and store the byte of data. This is
  75.    referred to as an "interrupt on receive" terminal program, such as
  76.    our product, SLICK terminal.
  77.  
  78.    There are many things that can go wrong when installing a modem
  79.    on your computer. Usually, problems are evenly divided between
  80.    hardware and software configuration errors. In general, the modem
  81.    itself must be mechanically set, via jumper pins or dip switches,
  82.    to address whatever available serial port is usable on your PC.
  83.    The selected port must also be paired with an interrupt request line
  84.    (IRQ). Note, no two serial devices (examp: modem and mouse) may share
  85.    actively the same serial port IRQ address. Some modems force, or
  86.    allow you to force, certain register bits either high (1) or low (0)
  87.    in lieu of preferred software control. TestPort is useful in
  88.    EXAMINING all of the register settings that occur as a results of
  89.    these various configurations. Improper configuration of software is
  90.    another problem. Here, there are generally three areas of trouble.
  91.    Improper comm port, interrupt and modem command (initialization)
  92.    string settings. So, to review, One: the serial services must first
  93.    be available on the PC. Two: both the modem and terminal software
  94.    must agree in settings with the PC hardware you are attempting to
  95.    access. And finally, the modem initialization command string must
  96.    correctly complete the job of setting any other registers that
  97.    require attention, such as setting FAX mode on or off, hardware error
  98.    correction enabled or disabled, etc. etc. For what its worth, just
  99.    one wrong AT command in the string will cause the entire string to
  100.    FAIL. So, if your particular brand modem does not use &D1 (set dtr)
  101.    as an example, and, it is inserted into your complete string, such as
  102.    ATM1S0=0V1X4&D1S7=45, then the entire string will fail returning an
  103.    error message, leaving your modem still waiting to be configured.
  104.  
  105.    ====================================================================
  106.    USING TestPort's register mapping ability:
  107.  
  108.    To run TestPort with mapping action, you must pass the active port
  109.    number via a command parameter. TestPort will work on the four
  110.    standard IBM default ports of 1 (3F8), 2 (2F8), 3 (3E8), and 4 (2E8).
  111.    Let's assume your modem is configured to operate using COM2. Type
  112.    TESTPORT 2 at the DOS prompt. In most cases, you will really want to
  113.    do this while your terminal program is active. You do this by
  114.    dropping to DOS from within your terminal program, then executing
  115.    TestPort. Most all Terminal programs have a drop to DOS feature,
  116.    although it might be called something else. TestPort does a passive
  117.    read only on these registers and therefore will in no way alter or
  118.    change their bit settings. By using the drop to dos feature, which
  119.    allows the modem code to remain loaded in ram, you eliminate the
  120.    possibility that any modem registers will be inadvertently altered,
  121.    by your terminal program, before you get to read the registers. Some
  122.    terminal programs also have features that allow the naming and
  123.    execution of any external dos utility via a combination of trigger
  124.    hot keys. This is a MUCH better way of quickly running TestPort.
  125.    Don't forget in either case to pass the active port number in use.
  126.    (i.e. TESTPORT 2.)  If TestPort is executed as an external utility,
  127.    screen output data will remain until a key is pressed. This will give
  128.    you opportunity to hit Shft PrtSc and save a copy of the screen to
  129.    your printer for evaluation and analysis. If you do not have a
  130.    printer, you should make a long hand record on paper.
  131.  
  132.    USING TestPort's UART finder:
  133.  
  134.    Running TestPort without a port parameter will cause TestPort to
  135.    cycle through the four common UART addresses looking for an active
  136.    (U)niversal (A)synchronous (C)ommunications (C)ontroller. (8250 IC)
  137.    If active port addresses are located, TestPort will notify you of
  138.    those that appeared active. Notice, I said appeared active. It is
  139.    possible to have two serial ports but only one terminated to a
  140.    modem. The other may be just a jack on the rear of your PC, there
  141.    for some later expansion. A simple serial card with its open jack
  142.    will still show as an active port.
  143.  
  144.    Screen Output:
  145.    ------------------------------------------------------------------------
  146.    The Correct Syntax is TESTPORT #, (# to test), i.e. TESTPORT 4,
  147.    however, TestPort will now try to determine what if any serial
  148.    port is responding to TestPort's Inquiries....................
  149.  
  150.    COM1 appears to have an active UART!
  151.    COM2 appears to be inactive.
  152.    COM3 appears to be inactive.
  153.    COM4 appears to have an active UART!
  154.  
  155.    Enter Port# to test or Esc to exit ->
  156.  
  157.    In five seconds type AT <Enter>, active port will echo OK or 0, else Esc!
  158.    ------------------------------------------------------------------------
  159.  
  160.    Although this kind of information is by far un-conclusive, it does
  161.    give you enough insights to continue experimenting. In the case of
  162.    the information given above, the modem must be attached to either
  163.    COM1 or COM4. To determine which it is, try entering 1 first. If
  164.    there is no echoing of your keystroke or an OK reply to AT (the modem
  165.    attention command) the probability is COM1 is not the port connected
  166.    to your modem. Now try 4. This should test ok! More than likely, COM1
  167.    is an extra, as of yet unused, serial adapter.
  168.  
  169.    Although this testing facility is only a raw polling terminal, set to
  170.    1200 baud, N81, it can easily be used for simple task, like dialing
  171.    out to test other modems etc. Try typing ATH1 and see if you hear
  172.    your modem take the line off hook....ATH0 to replace it. Fun hun?
  173.  
  174.    ====================================================================
  175.    SCREEN GENERATED BY TESTPORT when mapping registers:
  176.  
  177.    When TestPort is run, it produces the following screen, indicating
  178.    the various one byte registers that have been read, their decimal,
  179.    hex, and (binary) bit map values. It's those bit settings you are
  180.    most interested in. The two indirect registers (THR and RDR) read
  181.    via the base register are not useful here. However, those two plus
  182.    the eight indicated account for the 10 registers of a UART chip.
  183.  
  184.          *******************************************************
  185.              Modem Register Bit Map by Gary M. Raymond SSC
  186.                         Phone (504) 288-6550
  187.  
  188.          Modem Registers     Dec Value    Hex Value     Bit Map
  189.                                                         76543210
  190.          IER (Int Enable)             0           00    00000000
  191.          IIR (Int ID)                 1           01    00000001
  192.          LCR (Line Control)           3           03    00000011
  193.          MCR (Modem Cont)             8           08    00001000
  194.          LSR (Line Status)           97           61    01100001
  195.          MSR (Modem Status)          48           30    00110000
  196.          BRDL (Low Register)          6           06    00000110
  197.          BRDH (Hi  Register)          0           00    00000000
  198.          *******************************************************
  199.  
  200.  
  201.          Hit Any Key to Exit!
  202.  
  203.  
  204.  
  205.    NOTE: Bit positions are read left to right, starting with position
  206.          0 (zero) and ending with 7. This accounts for a full byte of
  207.          eight bits.
  208.  
  209.    ====================================================================
  210.    SAMPLE USES for TESTPORT:
  211.  
  212.    Q) My modem wont hang up, what do I look for?
  213.    A) Look at bits 0 and 1 of MCR after starting your terminal program
  214.       but before dialing a number. They should both be set to 1. If not
  215.       check to see if your modem requires external dip switch settings
  216.       to force DTR, RTS or software AT commands like &D2 and &C1.
  217.  
  218.    Q) How can I tell if my terminal program is interrupt driven or
  219.       a polling BIOS type?
  220.    A) Look at bit 0 of IER, it will be set to 1 if the terminal is
  221.       interrupt driven. Also, bit 3 of MCR is usually set to 1 as
  222.       well. These bits are set to 0 (zero) in a polling terminal.
  223.  
  224.    Q) My modem wont respond on COM2.
  225.    A) Run TESTPORT 2. If If you see each modem register returning FF hex
  226.       (dec 255 or 11111111 binary) odds are this port is not activated
  227.       correctly via pin or dip settings on the modem card. Check your
  228.       modem manual for correct pin or dip switch settings.
  229.  
  230.    Q) How can I tell what Baud rate my modem is locked at?
  231.    A) First, run TestPort and obtain the BRDL and BRDH register values.
  232.       Then cross reference them with the Baud Rate Value chart in this
  233.       document file.
  234.  
  235.    Q) Can I use TestPort to call a BBS?
  236.    A) Yes, but it's VERY limited as a polling terminal and not intended
  237.       for that kind of application.
  238.  
  239.    Q) What else can TestPort do?
  240.    A) The registered version can correct an omission of some versions
  241.       of DOS that limit bios serial communications to COM1 and COM2 by
  242.       poking the IBM default addresses (3E8 - 2E8)into the proper area
  243.       of bios memory. (Seg 0040 Ofs 04,06) This will remain usable until
  244.       you reboot.
  245.  
  246.    ====================================================================
  247.    MODEM REGISTER BIT MAP DATA:
  248.  
  249.        For general purpose information, the port addresses of
  250.        these registers are as follows:
  251.  
  252.        BASE = COMPORT ADDRESS  (COM1 = 3F8h)
  253.        Therefore, MCR for COM1 equals 3F8h + 4 or 3FCh
  254.  
  255.        Ten Modem Registers
  256.        ---------------------------------------------
  257.        THR,RDR, *BRDL =  BASE
  258.        IER,     *BRDH =  BASE  + 1  ;  Interrupt Enable Register
  259.        IIR            =  BASE  + 2  ;  Interrupt Identification Register
  260.        LCR            =  BASE  + 3  ;  Line Control Register
  261.        MCR            =  BASE  + 4  ;  Modem Control Register
  262.        LSR            =  BASE  + 5  ;  Line Status Register
  263.        MSR            =  BASE  + 6  ;  Modem Status Register
  264.        ---------------------------------------------
  265.                 *requires bit 7 set to 1 in LCR for access
  266.    ====================================================================
  267.  
  268.        IER  BIT MAPPING   (Interrupt Enable Register)
  269.        ---------------------------------------------
  270.        BIT     Activates             Action
  271.        0    =  Data Received         Read RDR
  272.        1    =  THR empty             Output to THR
  273.        2    =  Data error/break      Read LSR
  274.        3    =  MSR change            Read MSR
  275.        4    =  zero
  276.        5    =  zero
  277.        6    =  zero
  278.        7    =  zero
  279.  
  280.        Although the 8250 Uart has 10 one byte registers, only seven have
  281.        direct access, and of the seven, three of these are used
  282.        redundantly to gain access to the three non directly accessible
  283.        registers. This indirect access is achieved by setting bit 7 of
  284.        LSR to 1. Then, the BRDL and BRDH registers are accesses at BASE
  285.        and BASE + 1. These two registers are used to lock the port baud
  286.        rate. The BRD (Baud Rate Divisor) is a 16 bit number (two bytes)
  287.        and therefore requires two (one byte) register access through
  288.        BASE and BASE + 1. Interesting enough, the high byte is only
  289.        necessary for baud rates of 300 or below. At 1200 or higher BRDH
  290.        is set at zero. The formula for calculating the BRD value
  291.        demonstrates why.
  292.  
  293.                       UART CLOCK SPEED (1.8432mhz)
  294.               BRD =   ----------------------------
  295.                       16 x bit transfer rate (not really baud)
  296.  
  297.                       1,843,200
  298.               BRD =   ---------   =   256 or    110000000  or 100h
  299.                       16 x 300
  300.                                                 B   B
  301.                                                 R   R
  302.                                                 D   D
  303.                       breaking the result into  H   L
  304.                       two bytes produces =      1 & 1000000
  305.  
  306.                       where BRDH = 1hex and BRDL = 80h (128 dec)
  307.  
  308.               FOR 1200 BAUD:
  309.  
  310.                       1,843,200
  311.               BRD =   ---------   =   96 or    1100000  or 60h
  312.                       16 x 1200
  313.                                                 B   B
  314.                                                 R   R
  315.                                                 D   D
  316.                       breaking the result into  H   L
  317.                       two bytes produces =      0 & 1100000
  318.  
  319.                       where BRDH = 0hex and BRDL = 60h (96 dec)
  320.  
  321.  
  322.        The THR (Transmit Holding Register) and RDR (Received Data Register)
  323.        are accessed via the same physical address as the port base address.
  324.        Since you cannot in theory send and receive at the same instant, this
  325.        little scheme seems ok.
  326.  
  327.  
  328.  
  329.        IIR  BIT MAPPING   (Interrupt Identification Register)
  330.        ---------------------------------------------
  331.        BIT
  332.        0    =  more than 1 intr has occurred
  333.  
  334.                12                       12
  335.        1-2  =  00  change in MSR        10    data received
  336.                01  THR empty            11    recv error/break
  337.  
  338.        3    =  zero
  339.        4    =  zero
  340.        5    =  zero
  341.        6    =  zero
  342.        7    =  zero
  343.  
  344.  
  345.        LCR  BIT MAPPING   (Line Control Register)
  346.        ---------------------------------------------
  347.        BIT                      01                 01
  348.        01   =  Data Length      00=5bits           10=7bits
  349.                                 01=6bits           11=8bits
  350.  
  351.        2    =  Stop Bits        0=1bit             1=2bits
  352.  
  353.                                 345                345
  354.        345  =  Parity           000=NONE           101=MARK
  355.                                 100=ODD            111=SPACE
  356.                                 110=EVEN
  357.  
  358.        6    =  Break Condition  0=disabled         1=enabled
  359.        7    =  Port Toggle      0=Use THR/RDR/IER  1=Use BRDL/BRDH
  360.  
  361.  
  362.        SAMPLE: Using N parity, 8 data bits and 1 stop bit requires
  363.        the LCR register of 00000000 to be then set as follows:
  364.                            76543210 = bit pattern
  365.                                  11 = 8 bits
  366.                                 0   = 1 stop bit
  367.                              000    = no parity
  368.                             0       = break disabled
  369.                            0        = toggle inactive
  370.                          ----------
  371.                            00000011 = 3h to send to LCR
  372.  
  373.  
  374.        Bit 7 of LCR controls the dual function of bits 0 and 1 in the
  375.        IER Register and should be set to zero in the above example.
  376.  
  377.  
  378.  
  379.        MCR  BIT MAPPING   (Modem Control Register)
  380.        ---------------------------------------------
  381.        BIT
  382.        0    =  Set DTR line active
  383.        1    =  Set RTS line active
  384.        2    =  USER BIT #1
  385.        3    =  USER BIT #2
  386.        4    =  UART loopback
  387.        5    =  zero
  388.        6    =  zero
  389.        7    =  zero
  390.  
  391.        Bit 3 is normally set to 1 for interrupt driven terminal
  392.        programs. Most programs force the modem to hang up by setting
  393.        bits 0 and 1 to 0. Modem software setup for these first two bits
  394.        therefore is usually 1 and 1.
  395.  
  396.  
  397.        LSR  BIT MAPPING   (Line Status Register)
  398.        ---------------------------------------------
  399.        BIT
  400.        0    =  byte in RDR (received)
  401.        1    =  overrun in RDR
  402.        2    =  Parity error detected
  403.        3    =  Framing error (out of sync, no stop bit received)
  404.        4    =  Break Detect
  405.        5    =  THR empty
  406.        6    =  TSR empty (removes char from THR)
  407.        7    =  Time Out
  408.  
  409.  
  410.        A communications program usually checks bit 5 here before sending
  411.        another character out the base port.
  412.  
  413.  
  414.        MSR  BIT MAPPING   (Modem Status Register)
  415.        ---------------------------------------------
  416.        BIT
  417.        0    =  change in [C]lear [T]o [S]end  CTS
  418.        1    =  change in [D]ata [S]et [R]eady DSR
  419.        2    =  change in ring indicator RI
  420.        3    =  change in [D]ata [C]arrier [D]etect  DCD
  421.        4    =  Clear to send ..... [CTS] set high
  422.        5    =  Data set ready .... [DSR] set high
  423.        6    =  Ring Indicator .... [RI]  set high
  424.        7    =  Data Carrier detect [DCD] set high
  425.  
  426.        Most BBS programs monitor bit 7 of the MSR to determine
  427.        if carrier is lost during a logon.
  428.  
  429.    ===================================================================
  430.        BAUD RATE DIVISOR (BRD Register) CHART
  431.  
  432.        Bit Rate            BRDH           BRDL
  433.        ---------------------------------------
  434.        50                   09h            00h
  435.        110                  04h            17h
  436.        300                  01h            80h
  437.        ---------------------------------------
  438.        1200                 00h            60h   From 1200 up, BRDH is
  439.        2400                 00h            30h   always set to zero!
  440.        4800                 00h            18h
  441.        9600                 00h            0Ch
  442.        19200                00h            06h
  443.  
  444.    ===================================================================
  445.  
  446.    Registering your copy will help continue the competitive advantages
  447.    of providing economical shareware. As an additional bonus, I will
  448.    ship you several other useful modem and dos utilities free!  If
  449.    you have any comments or suggestions about this utility, feel free
  450.    to write or call.
  451.  
  452.    Name_____________________________________________________________
  453.  
  454.    Mailing Address__________________________________________________
  455.  
  456.    City & State ___________________________________________________
  457.  
  458.    ZIP _____________________________ Phone _________________________
  459.  
  460.    Send $4 + $1 (ship & hand) check or money order to:
  461.  
  462.                               Gary M. Raymond
  463.                                 P.O.Box 8184
  464.                             New Orleans, La. 70182
  465.                                 504-288-6550
  466.    ====================================================================
  467.                                      EOF
  468.  
  469.